import java.util.Arrays;

class Solution {
    public int removeElement(int[] nums, int val) {

        int left = 0;
        int right = 0;
        while (right < nums.length){
            if(nums[right] != val) {
                nums[left] = nums[right];
                right++;
                left++;
            }else right++;
        }
        int[] retNUm = new int[left];
        for (int i = 0; i < left; i++) {
            retNUm[i] = nums[i];
        }
        nums = retNUm;
        return nums.length;
    }
}